package ui.forms;

import base.Food;
import com.sun.lwuit.Component;
import com.sun.lwuit.Label;
import com.sun.lwuit.List;
import com.sun.lwuit.list.ListCellRenderer;
import ui.ColoredBox;

/**
 *
 * @author Shayan
 */
class AddFoodListRenderer extends Label implements ListCellRenderer {

    ColoredBox focusComponent;
    Label cell;

    public AddFoodListRenderer() {
        focusComponent = new ColoredBox(0x336699);
        cell = new Label();
        cell.getStyle().setBgImage(null);
        cell.getStyle().setBgTransparency(0);
    }

    public Component getListCellRendererComponent(List list, Object value, int index, boolean isSelected) {

        Food food = (Food) value;

        cell.setText(food == null ? "" : food.getName());
        return cell;
    }

    public Component getListFocusComponent(List list) {
        return focusComponent;
    }
}

